package zhuyun.code.launcheractivity.utils

import android.content.Context
import android.content.SharedPreferences
import zhuyun.code.launcheractivity.App

/**
 * @author: Administrator
 * @date: 2021/11/18
 */
object SPUtils {
    private val context = App.context
    private val sharedPreference = context.getSharedPreferences("com.zhuyun.code", Context.MODE_PRIVATE)
    private val userSharedPreference = context.getSharedPreferences("com.zhuyun.code.UserInfo",Context.MODE_PRIVATE)

    fun putUserBoolean(key:String, value:Boolean){
        val editor = userSharedPreference.edit()
        editor.putBoolean(key,value)
        editor.commit()
    }

    fun getUserBoolean(key:String, defaultValue: Boolean):Boolean{
        return userSharedPreference.getBoolean(key, defaultValue)
    }

    fun putUserInt(key: String,value: Int){
        val editor = userSharedPreference.edit()
        editor.putInt(key,value)
        editor.commit()
    }

    fun getUserInt(key:String, defaultValue: Int):Int{
        return userSharedPreference.getInt(key,defaultValue)
    }

    fun putUserLong(key:String,value:Long){
        val editor = userSharedPreference.edit()
        editor.putLong(key,value)
        editor.commit()
    }

    fun getUserLong(key:String,defaultValue: Long):Long{
        return userSharedPreference.getLong(key,defaultValue)
    }

    fun putUserString(key:String, value:String?){
        val editor = userSharedPreference.edit()
        editor.putString(key,value)
        editor.commit()
    }

    fun getUserString(key:String, defaultValue: String?):String?{
        return userSharedPreference.getString(key,defaultValue)
    }

    fun putBoolean(key:String,value:Boolean){
        val editor = sharedPreference.edit()
        editor.putBoolean(key,value)
        editor.commit()
    }

    fun getBoolean(key:String, defaultValue:Boolean):Boolean{
        return sharedPreference.getBoolean(key,defaultValue)
    }

    fun putInt(key:String,value:Int){
        val editor = sharedPreference.edit()
        editor.putInt(key,value)
        editor.commit()
    }

    fun getInt(key:String,defaultValue: Int):Int{
        return sharedPreference.getInt(key,defaultValue)
    }

    fun putLong(key:String, value:Long){
        val editor = sharedPreference.edit()
        editor.putLong(key,value)
        editor.commit()
    }

    fun getLong(key:String, defaultValue:Long):Long{
        return sharedPreference.getLong(key, defaultValue)
    }

    fun putString(key:String,value:String){
        val editor = sharedPreference.edit()
        editor.putString(key,value)
        editor.commit()
    }

    fun getString(key:String,defaultValue: String):String?{
        return sharedPreference.getString(key,defaultValue)
    }




}